package com.sgb.net.entity;

import com.google.gson.annotations.SerializedName;

/**
 * @author: 杨畔
 * @date: 2021/2/19 14:56
 * @Description: 数据基类
 */
public class BaseEntity<D> implements EntityInterface<D> {
    public String code;
    public String errCode;
    public String payload;
    private String msg;
    @SerializedName(
            value = "data",
            alternate = {"result", "records"}
    )
    private D data;
    @SerializedName(
            value = "state",
            alternate = {"status"}
    )
    private String state;

    public BaseEntity() {
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public D getData() {
        return this.data;
    }

    public void setData(D data) {
        this.data = data;
    }

    public String getState() {
        return this.state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String code() {
        return null;
    }

    public String msg() {
        return this.msg;
    }

    public D data() {
        return this.data;
    }

    public boolean isSuccess() {
        return "ok".equals(this.state);
    }
}
